/**
 * 
 */
package org.ucn.dmaa0914.gruppe6;

import java.util.ArrayList;

/**
 * @author Kim
 *
 */
public abstract class CrudController<T> {
	
	private Container<T> container;
	
	public CrudController()
	{
		container = new Container<T>();
	}
	
	public T create()
	{
		T obj = newObject();
		container.add(obj);
		return obj;
	}
	
	public void delete(int id)
	{
		container.remove(find(id));
	}
	
	public T find(int id)
	{
		return container.find(id);
	}
	public ArrayList<T> search(String data)
	{
		return container.search(data, getSearchFilter());
	}
	
	public abstract String format(int id);	
	protected abstract SearchFilter<T> getSearchFilter();
	protected abstract T newObject();
}
